package com.appwoo.txtws.activity;

import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.appwoo.android.exception.NotFoundNetWorkException;
import com.appwoo.android.exception.TimeOutException;
import com.appwoo.txtws.adapter.SoftUrlApapter;
import com.appwoo.txtws.app.AppActivity;
import com.appwoo.txtws.bean.MessageBean;
import com.appwoo.txtws.bean.RecordSoftBean;
import com.appwoo.txtws.bean.Record_SoftBean;
import com.appwoo.txtws.bean.StateBean;
import com.appwoo.txtws.component.ImageZoomView;
import com.appwoo.txtws.component.Logger;
import com.appwoo.txtws.component.RqSP;
import com.appwoo.txtws.component.SimpleZoomListener;
import com.appwoo.txtws.component.ZoomState;
import com.appwoo.txtws.service.SoftLimitService;
import com.appwoo.txtws.service.SoftService;
import com.appwoo.txtws.service.WebService;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Iterator;
import java.util.List;
import org.xmlpull.v1.XmlPullParserException;

public class RecordSoftUrlActivity extends AppActivity
{
  private static final int DIALOG1 = 1;
  private LinearLayout RelativeLayout_info;
  private RelativeLayout RelativeLayout_message;
  private TextView TextView_bl;
  private TextView TextView_name;
  private TextView TextView_num;
  private TextView TextView_time;
  private TextView TextView_type;
  private String equipName = "";
  private List<RecordSoftBean> f_buyLogList = null;
  private String f_date = null;
  private List<Record_SoftBean> f_newList = null;
  private SoftLimitService f_softLimitService = null;
  private SoftService f_softService;
  private WebService f_webService;
  private String f_webType = null;
  private SoftUrlApapter f_webUrlApapter;
  private List<Record_SoftBean> infoBeans = null;
  private LinearLayout linearlayout_record_null;
  private String mapUrl = "";
  private Bitmap mianMap;
  private int page = 1;
  Record_SoftBean recordSoftBean = null;
  private String selectSoft = "";
  private String userId = "";
  private ListView v_listview_record_weburl_list;
  private ProgressDialog v_progressDialog = null;
  private ImageZoomView v_zoomImage_big;

  private void addBackListener()
  {
    if (this.RelativeLayout_info.getVisibility() == 4)
    {
      setResult(-1, getIntent());
      finish();
      return;
    }
    this.RelativeLayout_message.setVisibility(0);
    showBarHome();
    this.RelativeLayout_info.setVisibility(4);
    setBarTitle(getString(2131427822));
    setResult(-1, getIntent());
  }

  private void addLisenter()
  {
    addMoreListListener();
    addListCilckListener();
    conmitButtonLisstener();
  }

  private void addListCilckListener()
  {
    this.v_listview_record_weburl_list.setOnItemClickListener(new AdapterView.OnItemClickListener()
    {
      public void onItemClick(AdapterView<?> paramAnonymousAdapterView, View paramAnonymousView, int paramAnonymousInt, long paramAnonymousLong)
      {
        RecordSoftUrlActivity.this.recordSoftBean = ((Record_SoftBean)paramAnonymousAdapterView.getItemAtPosition(paramAnonymousInt));
        if ((RecordSoftUrlActivity.this.recordSoftBean != null) && (RecordSoftUrlActivity.this.recordSoftBean.getPath() != null) && (!RecordSoftUrlActivity.this.recordSoftBean.getPath().equals("")))
        {
          String str = RecordSoftUrlActivity.this.recordSoftBean.getPath();
          if (!str.equals(RecordSoftUrlActivity.this.mapUrl))
          {
            RecordSoftUrlActivity.this.mapUrl = str;
            new RecordSoftUrlActivity.OperateLogAsyncTask(RecordSoftUrlActivity.this).execute(new String[] { "pic" });
          }
        }
        while (true)
        {
          RecordSoftUrlActivity.this.TextView_name.setText(RecordSoftUrlActivity.this.recordSoftBean.getGameName());
          RecordSoftUrlActivity.this.TextView_time.setText(RecordSoftUrlActivity.this.recordSoftBean.getVisitedTime());
          RecordSoftUrlActivity.this.TextView_num.setText(RecordSoftUrlActivity.this.recordSoftBean.getNum());
          RecordSoftUrlActivity.this.RelativeLayout_message.setVisibility(4);
          RecordSoftUrlActivity.this.hideBarHome();
          RecordSoftUrlActivity.this.RelativeLayout_info.setVisibility(0);
          RecordSoftUrlActivity.this.setBarTitle(RecordSoftUrlActivity.this.getString(2131427819));
          return;
          RecordSoftUrlActivity.this.postBigMap();
          continue;
          RecordSoftUrlActivity.this.v_zoomImage_big.setImage(null);
        }
      }
    });
  }

  private void addMoreListListener()
  {
    this.v_listview_record_weburl_list.setOnScrollListener(new AbsListView.OnScrollListener()
    {
      public void onScroll(AbsListView paramAnonymousAbsListView, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3)
      {
      }

      public void onScrollStateChanged(AbsListView paramAnonymousAbsListView, int paramAnonymousInt)
      {
        if ((paramAnonymousInt == 0) && (paramAnonymousAbsListView.getLastVisiblePosition() == -1 + paramAnonymousAbsListView.getCount()))
          new RecordSoftUrlActivity.RecordSoftUrAsyncTask(RecordSoftUrlActivity.this).execute(new String[] { "more" });
      }
    });
  }

  private void addRefashListemer()
  {
    new RecordSoftUrAsyncTask().execute(new String[] { "init" });
  }

  private String bgAddLimit()
  {
    try
    {
      String str = this.f_softLimitService.addLimitSoft(this.userId, "", this.selectSoft, this).getCode();
      return str;
    }
    catch (IOException localIOException)
    {
      return getString(2131427525);
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      return getString(2131427525);
    }
    catch (TimeOutException localTimeOutException)
    {
      return getString(2131427525);
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      localNotFoundNetWorkException.getClass();
    }
    return "没有连接到网络";
  }

  private String bgBigPig()
  {
    try
    {
      String str = this.mapUrl;
      int i = str.lastIndexOf('/');
      URL localURL2 = new URL(str.substring(0, i) + "/" + URLEncoder.encode(str.substring(i + 1)));
      localURL1 = localURL2;
    }
    catch (MalformedURLException localMalformedURLException)
    {
      try
      {
        while (true)
        {
          HttpURLConnection localHttpURLConnection = (HttpURLConnection)localURL1.openConnection();
          localHttpURLConnection.setReadTimeout(20000);
          localHttpURLConnection.setConnectTimeout(3000);
          localHttpURLConnection.setDoInput(true);
          localHttpURLConnection.connect();
          InputStream localInputStream = localHttpURLConnection.getInputStream();
          this.mianMap = BitmapFactory.decodeStream(localInputStream);
          localInputStream.close();
          return "";
          localMalformedURLException = localMalformedURLException;
          localMalformedURLException.printStackTrace();
          URL localURL1 = null;
        }
      }
      catch (Exception localException)
      {
      }
    }
    return getString(2131427602);
  }

  private String bgInitBuyLogList()
  {
    try
    {
      this.page = 1;
      this.infoBeans = this.f_webService.getRecordGameInfo(this.userId, this.equipName, this.f_date, this.page, this);
      return "";
    }
    catch (IOException localIOException)
    {
      return getString(2131427525);
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      return getString(2131427525);
    }
    catch (TimeOutException localTimeOutException)
    {
      return getString(2131427525);
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      localNotFoundNetWorkException.getClass();
    }
    return "没有连接到网络";
  }

  private String bgMoreBuyLogList()
  {
    try
    {
      this.page = (1 + this.page);
      this.f_newList = this.f_webService.getRecordGameInfo(this.userId, this.equipName, this.f_date, this.page, this);
      return "";
    }
    catch (IOException localIOException)
    {
      return getString(2131427525);
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      return getString(2131427525);
    }
    catch (TimeOutException localTimeOutException)
    {
      return getString(2131427525);
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      localNotFoundNetWorkException.getClass();
    }
    return "没有连接到网络";
  }

  private void bgShowOBuyLogList()
  {
    this.v_listview_record_weburl_list.setAdapter(getAdapter(this.infoBeans));
  }

  private Dialog buildDialog(Context paramContext)
  {
    AlertDialog.Builder localBuilder = new AlertDialog.Builder(paramContext);
    localBuilder.setIcon(2130837508);
    localBuilder.setTitle("是否添加到限制列表?");
    localBuilder.setPositiveButton(getString(2131427513), new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
      {
        if (RecordSoftUrlActivity.this.selectSoft != null)
          new RecordSoftUrlActivity.RecordSoftUrAsyncTask(RecordSoftUrlActivity.this).execute(new String[] { "add" });
      }
    });
    localBuilder.setNegativeButton(getString(2131427514), new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
      {
      }
    });
    return localBuilder.create();
  }

  private String commitBlist()
  {
    try
    {
      Record_SoftBean localRecord_SoftBean = this.recordSoftBean;
      localObject = null;
      if (localRecord_SoftBean != null)
      {
        MessageBean localMessageBean = this.f_webService.blackListGameCommit(this.userId, this.equipName, this.recordSoftBean.getGameName(), this.recordSoftBean.getProcName(), this.recordSoftBean.getAuthor(), this.recordSoftBean.getVisitedTime(), this.recordSoftBean.getType(), this.recordSoftBean.getPath1(), this.recordSoftBean.getSha1(), this);
        localObject = localMessageBean;
      }
      if (localObject != null)
        return localObject.getCode();
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        localIOException.printStackTrace();
        localObject = null;
      }
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      while (true)
      {
        localXmlPullParserException.printStackTrace();
        localObject = null;
      }
    }
    catch (TimeOutException localTimeOutException)
    {
      while (true)
      {
        localTimeOutException.printStackTrace();
        localObject = null;
      }
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      while (true)
      {
        localNotFoundNetWorkException.printStackTrace();
        Object localObject = null;
      }
    }
    return "";
  }

  private void conmitButtonLisstener()
  {
    this.TextView_bl.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        new RecordSoftUrlActivity.OperateLogAsyncTask(RecordSoftUrlActivity.this).execute(new String[] { "commit" });
      }
    });
  }

  private void createOrShowDialog()
  {
    if ((this.v_progressDialog == null) || (!this.v_progressDialog.isShowing()))
    {
      this.v_progressDialog = new ProgressDialog(this);
      this.v_progressDialog.setMessage(getString(2131427516));
      this.v_progressDialog.setCancelable(true);
    }
    try
    {
      this.v_progressDialog.show();
      return;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }

  private SoftUrlApapter getAdapter(List<Record_SoftBean> paramList)
  {
    if ((paramList != null) && (paramList.size() > 0));
    try
    {
      this.f_webUrlApapter = new SoftUrlApapter(this, paramList);
      this.f_webUrlApapter.notifyDataSetChanged();
      while (true)
      {
        label33: return this.f_webUrlApapter;
        alertMessage(getString(2131427821));
        this.linearlayout_record_null.setVisibility(0);
      }
    }
    catch (Exception localException)
    {
      break label33;
    }
  }

  private void getWebType()
  {
    Bundle localBundle = getIntent().getExtras();
    this.f_webType = localBundle.getString("webType");
    this.f_date = localBundle.getString("date");
    if ((this.f_webType == null) || (this.f_webType.equals("")))
    {
      alertMessage(getString(2131427818));
      finish();
    }
  }

  private void initActionBar()
  {
    setBarTitle(getResources().getString(2131427806));
    setBarBackOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        RecordSoftUrlActivity.this.addBackListener();
      }
    });
    setBarHomeDrawable(getResources().getDrawable(2130838067));
    setBarHomeOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        RecordSoftUrlActivity.this.addRefashListemer();
      }
    });
  }

  private void initView()
  {
    this.f_webService = new WebService();
    this.f_softService = new SoftService();
    this.f_softLimitService = new SoftLimitService();
    this.RelativeLayout_message = ((RelativeLayout)findViewById(2131493381));
    this.RelativeLayout_info = ((LinearLayout)findViewById(2131493363));
    this.RelativeLayout_info.setVisibility(4);
    this.linearlayout_record_null = ((LinearLayout)findViewById(2131493386));
    this.TextView_type = ((TextView)findViewById(2131493325));
    this.TextView_name = ((TextView)findViewById(2131493364));
    this.TextView_time = ((TextView)findViewById(2131493365));
    this.TextView_num = ((TextView)findViewById(2131493366));
    this.TextView_bl = ((TextView)findViewById(2131493367));
    this.v_listview_record_weburl_list = ((ListView)findViewById(2131493385));
    this.v_zoomImage_big = ((ImageZoomView)findViewById(2131493028));
    RqSP localRqSP = new RqSP();
    this.equipName = localRqSP.getLgDevId(this);
    this.userId = localRqSP.getLgDevAccount(this);
  }

  private void postBigMap()
  {
    if (this.mianMap != null)
    {
      this.v_zoomImage_big.setImage(this.mianMap);
      this.v_zoomImage_big.setBackgroundColor(-16777216);
      ZoomState localZoomState = new ZoomState();
      this.v_zoomImage_big.setZoomState(localZoomState);
      SimpleZoomListener localSimpleZoomListener = new SimpleZoomListener();
      localSimpleZoomListener.setZoomState(localZoomState);
      this.v_zoomImage_big.setOnTouchListener(localSimpleZoomListener);
      localZoomState.setPanX(0.5F);
      localZoomState.setPanY(0.5F);
      localZoomState.setZoom(1.0F);
      localZoomState.notifyObservers();
      return;
    }
    Logger.i("TXTW", "mianMap==NULL");
  }

  private void postMoreBuyLogList()
  {
    if ((this.f_newList != null) && (this.f_newList.size() > 0))
    {
      Iterator localIterator = this.f_newList.iterator();
      while (true)
      {
        if (!localIterator.hasNext())
        {
          this.f_webUrlApapter.notifyDataSetChanged();
          this.f_newList = null;
          return;
        }
        Record_SoftBean localRecord_SoftBean = (Record_SoftBean)localIterator.next();
        this.f_webUrlApapter.add(localRecord_SoftBean);
      }
    }
    this.page = (-1 + this.page);
    alertMessage(getString(2131427519));
  }

  private void showPieViewValue()
  {
    new RecordSoftUrAsyncTask().execute(new String[] { "init" });
  }

  public void PostShowAddInfo(String paramString)
  {
    if (paramString.equals("0"))
    {
      alertMessage(getString(2131427520));
      return;
    }
    alertMessage(getString(2131427521));
  }

  protected void backKeyCallBack()
  {
    super.backKeyCallBack();
    addBackListener();
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903182);
    initView();
    initActionBar();
    getWebType();
    addLisenter();
    showPieViewValue();
  }

  protected Dialog onCreateDialog(int paramInt)
  {
    switch (paramInt)
    {
    default:
      return null;
    case 1:
    }
    return buildDialog(this);
  }

  public class OperateLogAsyncTask extends AsyncTask<String, Integer, String>
  {
    private String method = "";

    public OperateLogAsyncTask()
    {
    }

    protected String doInBackground(String[] paramArrayOfString)
    {
      this.method = paramArrayOfString[0];
      if (this.method.equals("pic"))
        return RecordSoftUrlActivity.this.bgBigPig();
      if (this.method.equals("commit"))
        return RecordSoftUrlActivity.this.commitBlist();
      return "";
    }

    protected void onPostExecute(String paramString)
    {
      if (this.method.equals("pic"))
        RecordSoftUrlActivity.this.postBigMap();
      while (true)
      {
        RecordSoftUrlActivity.this.v_progressDialog.dismiss();
        return;
        if (this.method.equals("commit"))
          if (paramString.equals("0"))
            RecordSoftUrlActivity.this.alertMessage(RecordSoftUrlActivity.this.getString(2131427527));
          else
            RecordSoftUrlActivity.this.alertMessage(RecordSoftUrlActivity.this.getString(2131427528));
      }
    }

    protected void onPreExecute()
    {
      RecordSoftUrlActivity.this.createOrShowDialog();
    }
  }

  public class RecordSoftUrAsyncTask extends AsyncTask<String, Integer, String>
  {
    private String method = "";

    public RecordSoftUrAsyncTask()
    {
    }

    protected String doInBackground(String[] paramArrayOfString)
    {
      this.method = paramArrayOfString[0];
      if (this.method.equals("init"))
        return RecordSoftUrlActivity.this.bgInitBuyLogList();
      if (this.method.equals("refash"))
        return RecordSoftUrlActivity.this.bgInitBuyLogList();
      if (this.method.equals("more"))
        return RecordSoftUrlActivity.this.bgMoreBuyLogList();
      if (this.method.equals("add"))
        return RecordSoftUrlActivity.this.bgAddLimit();
      return "";
    }

    protected void onPostExecute(String paramString)
    {
      if (this.method.equals("init"))
        RecordSoftUrlActivity.this.bgShowOBuyLogList();
      try
      {
        while (true)
        {
          RecordSoftUrlActivity.this.v_progressDialog.dismiss();
          return;
          if (this.method.equals("refash"))
            RecordSoftUrlActivity.this.bgShowOBuyLogList();
          else if (this.method.equals("more"))
            RecordSoftUrlActivity.this.postMoreBuyLogList();
          else if (this.method.equals("add"))
            RecordSoftUrlActivity.this.PostShowAddInfo(paramString);
        }
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
      }
    }

    protected void onPreExecute()
    {
      RecordSoftUrlActivity.this.createOrShowDialog();
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.activity.RecordSoftUrlActivity
 * JD-Core Version:    0.6.2
 */